package m.base.model;

import m.common.model.DictionaryModel;
import m.common.model.FieldMeta;
import m.common.model.TableMeta;
import m.common.model.type.FieldType;
import m.common.model.util.ModelQueryList;
import m.common.model.util.QueryCondition;
import m.common.model.util.QueryOrder;
import m.system.cache.FlushCache;
import manage.model.StatusModel;

import java.util.List;

@TableMeta(name="tb_level_info",description="级别信息")
public class LevelInfo extends StatusModel implements FlushCache, DictionaryModel {
    @FieldMeta(name="name",type= FieldType.STRING,length=50,description="名称")
    private String name;
    @FieldMeta(name="color",type= FieldType.STRING,length=20,description="颜色",dictType = "color")
    private String color;
    @FieldMeta(name="sort",type=FieldType.INT,description="排序")
    private Integer sort;
    @FieldMeta(name="def_level",type= FieldType.STRING,description="默认级别",dictOption = "Y:是,N:否")
    private String defLevel;
    @FieldMeta(name="apply_level",type= FieldType.STRING,description="注册级别",dictOption = "Y:是,N:否")
    private String applyLevel;

    @FieldMeta(name="user_num",type=FieldType.INT,defaultValue = "1",description="用户数量")
    private Integer userNum;
    @FieldMeta(name="repository_num",type=FieldType.INT,defaultValue = "1",description="仓库数量")
    private Integer repositoryNum;
    public final static String Yes="Y";
    public final static String No="N";
    @FieldMeta(name="offer_func",type= FieldType.STRING,description="报价单功能",dictOption = "Y:是,N:否")
    private String offerFunc;
    @FieldMeta(name="collect_func",type= FieldType.STRING,description="统计汇总功能",dictOption = "Y:是,N:否")
    private String collectFunc;
    @FieldMeta(name="export_func",type= FieldType.STRING,description="导出功能",dictOption = "Y:是,N:否")
    private String exportFunc;
    @FieldMeta(name="chart_func",type= FieldType.STRING,description="图表功能",dictOption = "Y:是,N:否")
    private String chartFunc;

    @FieldMeta(name="month_old_amount",type= FieldType.DOUBLE,defaultValue = "0",description="原月功能费")
    private Double monthOldAmount;
    @FieldMeta(name="month_amount",type= FieldType.DOUBLE,defaultValue = "0",description="月功能费")
    private Double monthAmount;
    @FieldMeta(name="year_amount",type= FieldType.DOUBLE,defaultValue = "0",description="年功能费")
    private Double yearAmount;

    public String getApplyLevel() {
        return applyLevel;
    }

    public void setApplyLevel(String applyLevel) {
        this.applyLevel = applyLevel;
    }

    public Double getMonthOldAmount() {
        return monthOldAmount;
    }

    public void setMonthOldAmount(Double monthOldAmount) {
        this.monthOldAmount = monthOldAmount;
    }

    public String getCollectFunc() {
        return collectFunc;
    }

    public void setCollectFunc(String collectFunc) {
        this.collectFunc = collectFunc;
    }

    public Double getMonthAmount() {
        return monthAmount;
    }

    public void setMonthAmount(Double monthAmount) {
        this.monthAmount = monthAmount;
    }

    public Double getYearAmount() {
        return yearAmount;
    }

    public void setYearAmount(Double yearAmount) {
        this.yearAmount = yearAmount;
    }

    public Integer getRepositoryNum() {
        return repositoryNum;
    }

    public void setRepositoryNum(Integer repositoryNum) {
        this.repositoryNum = repositoryNum;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getOfferFunc() {
        return offerFunc;
    }

    public void setOfferFunc(String offerFunc) {
        this.offerFunc = offerFunc;
    }

    public Integer getUserNum() {
        return userNum;
    }

    public void setUserNum(Integer userNum) {
        this.userNum = userNum;
    }

    public String getExportFunc() {
        return exportFunc;
    }

    public void setExportFunc(String exportFunc) {
        this.exportFunc = exportFunc;
    }

    public String getChartFunc() {
        return chartFunc;
    }

    public void setChartFunc(String chartFunc) {
        this.chartFunc = chartFunc;
    }

    public String getDefLevel() {
        return defLevel;
    }

    public void setDefLevel(String defLevel) {
        this.defLevel = defLevel;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Override
    public LevelInfo getCacheModel(String oid) throws Exception {
        return ModelQueryList.getModel(LevelInfo.class,oid,"*");
    }

    @Override
    public String getDictValue() {
        return getOid();
    }

    @Override
    public String getDictName() {
        return getName();
    }

    @Override
    public String getDictParentOid() {
        return "";
    }

    @Override
    public String getDictStatus() {
        return this.getStatus().equals("0") ? "Y" : "N";
    }

    @Override
    public List<LevelInfo> getCacheList(String s) throws Exception {
        return ModelQueryList.getModelList(LevelInfo.class,new String[]{"*"},null, QueryCondition.eq("status",StatusModel.Status_Enable), QueryOrder.asc("sort"));
    }
}
